package com.iwhalecloud.bss.kite.cucc.service.attr;

import com.iwhalecloud.bss.kite.common.constant.KeyConsts;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;

import java.util.Arrays;
import java.util.Optional;

/**
 * @author 付喆
 * @version 2021/5/25 21:33
 * Description:
 */
public class AttrModifyHelper {
    public static void displayAndNullable(KiteInst inst, String... fieldNames) {
        Arrays.stream(fieldNames)
            .forEach(fieldName -> Optional.ofNullable(inst.getAttr(fieldName)).ifPresent(kiteAttr -> {
                kiteAttr.setShowType(KeyConsts.PROD_ATTR_SHOW_TYPE_D);
                kiteAttr.setIsNull(KeyConsts.IFTRUE_T);
            }));
    }

    public static void moreAndNullable(KiteInst inst, String... fieldNames) {
        Arrays.stream(fieldNames)
            .forEach(fieldName -> Optional.ofNullable(inst.getAttr(fieldName)).ifPresent(kiteAttr -> {
                kiteAttr.setShowType(KeyConsts.PROD_ATTR_SHOW_TYPE_M);
                kiteAttr.setIsNull(KeyConsts.IFTRUE_T);
            }));
    }

    public static void displayAndNotNull(KiteInst inst, String... fieldNames) {
        Arrays.stream(fieldNames)
            .forEach(fieldName -> Optional.ofNullable(inst.getAttr(fieldName)).ifPresent(kiteAttr -> {
                kiteAttr.setShowType(KeyConsts.PROD_ATTR_SHOW_TYPE_D);
                kiteAttr.setIsNull(KeyConsts.IFTRUE_F);
            }));
    }

    public static void moreAndNotNull(KiteInst inst, String... fieldNames) {
        Arrays.stream(fieldNames)
            .forEach(fieldName -> Optional.ofNullable(inst.getAttr(fieldName)).ifPresent(kiteAttr -> {
                kiteAttr.setShowType(KeyConsts.PROD_ATTR_SHOW_TYPE_M);
                kiteAttr.setIsNull(KeyConsts.IFTRUE_F);
            }));
    }
}
